package br.ifpb.edu.asynctaskjson.asynctask;

import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.json.JSONObject;

import android.os.AsyncTask;
import android.util.Log;
import br.ifpb.edu.asynctaskjson.util.HttpService;
import br.ifpb.edu.asynctaskjson.util.HttpUtil;

public class LoginAsyncTask extends AsyncTask<JSONObject, Void, Integer> {

	@Override
	protected Integer doInBackground(JSONObject... jsons) {

		HttpResponse httpresponse = null;

		httpresponse = HttpService.sendJsonPostRequest("/loginpessoa", jsons[0]);

		// Passenger - Singleton
		String value = HttpUtil.entityToString(httpresponse);
		Log.i("EzCab", "User-json: " + value);

		return httpresponse != null ? httpresponse.getStatusLine()
				.getStatusCode() : HttpStatus.SC_SERVICE_UNAVAILABLE;
	}

	@Override
	protected void onPostExecute(Integer result) {

		Log.i("EzCab", "Access map-view: " + result);

	}
}
